package test;

public class ByteSizeException extends Exception {
	private int a;

	public ByteSizeException() {
		super();
	}

	public ByteSizeException(int a) {
		super();
		this.a = a;
	}

	public void check() throws ByteSizeException {
		if (a < -128 || a > 127) {
			throw new ByteSizeException();
		}
	}

	public static void main(String[] args) {
		ByteSizeException byteSizeException = new ByteSizeException(22);
		try {
			byteSizeException.check();
			System.out.println("属于byte类型");
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("数值范围超过byte范围");
		}
	}

}